package com.wanxin.wb.module.weixin.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.wanxin.wb.common.dao.oracle.master.IUserReadWriteDao;
import com.wanxin.wb.common.model.UserVO;
import com.wanxin.wb.module.weixin.service.ITranscationService;

@Service
public class TranscationService implements ITranscationService {
	
    private static Logger              LOG = LoggerFactory.getLogger(TranscationService.class);
	//
	@Autowired
	private IUserReadWriteDao   urserWriteDao;
	
	//批量新增
	/**
	 * 第1个成功  ，第二个失败 。事务回滚  总体失败
	 */
	@Transactional(propagation=Propagation.REQUIRED)
	public void  addBatch(){
		
		UserVO vo=new UserVO();
		vo.setMobile("1123");
		urserWriteDao.add(vo );
		
		LOG.info("执行新增1成功，参数 vo ="+JSONObject.toJSONString(vo ));
		UserVO vo1=new UserVO();
		//长度超长  抛出错误
		vo1.setMobile("1123111111111111111");
		urserWriteDao.add(vo1 );
	}

}
